﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using ClassLibrary.Entity;

public partial class en_MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadCSS();
            if (Session[Global.SESSION_LOGGED_USER] != null)
            {
                hypName.Text = "Welcome: " + ((TblAccounts)Session[Global.SESSION_LOGGED_USER]).FirstName + " " + ((TblAccounts)Session[Global.SESSION_LOGGED_USER]).LastName;
                hypName.NavigateUrl = "~/en/ManagerAccount.aspx";
                LoadTypeAcc();
                lnkLogout.Text = "Log Out";
                lvExpired.Text = ((TblAccounts)Session[Global.SESSION_LOGGED_USER]).DateExpiry.ToString("dd-MM-yyyy");
                hypLogin.Visible = false;
                hyRegister.Visible = false;
            }
            else
            {
                lnkLogout.Visible = false;
                hyManageAccount.Visible = false;
            }
        }
    }

    private void LoadCSS()
    {
        string idCSS = Global.GetPageName(Request.ServerVariables["SCRIPT_NAME"].ToString());
        if ((idCSS == "Default.aspx"))
        {
            aDef.Attributes.Add("class", "select");
        }
        if ((idCSS == "About.aspx"))
        {
            aAbout.Attributes.Add("class", "select");
        }
        if ((idCSS == "Upload.aspx"))
        {
            aUp.Attributes.Add("class", "select");
        }
        if ((idCSS == "CodeLayout.aspx"))
        {
            aGet.Attributes.Add("class", "select");
        }
        if ((idCSS == "UserGuide.aspx"))
        {
            aUser.Attributes.Add("class", "select");
        }
        if ((idCSS == "BecomeVIP.aspx"))
        {
            aBec.Attributes.Add("class", "select");
        }
        if ((idCSS == "Contact.aspx"))
        {
            aCon.Attributes.Add("class", "select");
        }


    }
    private void LoadTypeAcc()
    {
        int TypeAcc = ((TblAccounts)Session[Global.SESSION_LOGGED_USER]).TypeAcc;
        if (TypeAcc == 2)
            lbVip.Text = "Free";
        if (TypeAcc == 4)
            lbVip.Text = "VIP";
    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        Session[Global.SESSION_LOGGED_USER] = null;
        hypName.Text = "Customer";
        Response.Redirect("~/en/Default.aspx");
    }
}
